配置自己的数据库

OpenXava 使用 Hibernate 做为持久层, you need to indicate what database are you using in order that Hibernate generates the SQL statements with the correct syntaxt. You can choose any of the supported Hibernate dialects.

JPA entities (OX3 style)

例如, 假如你想把Hypersonic (the default when you create an OpenXava project)更改为 Oracle,
如果你正在使用OX3, 在你的项目下,编辑文件 persitence/META-INF/persistence.xml, 变更:
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>

<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>

如果你希望执行单元测试 (测试CRUD) 或者执行 ant task "updateSchema", 你也需要修改持久层单元关于:

<persistence-unit name="junit">
        <properties>
            <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
            <property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
            <property name="hibernate.connection.username" value="user"/>
            <property name="hibernate.connection.password" value="password"/>
        </properties>
    </persistence-unit>

同样地, if you wish your application database server to manage the user preferences tab (in this case Oracle) you need to modify the file persistence/openxava-hibernate.cfg indicating the correct datasource and dialect:

    <session-factory>
        <property name="hibernate.connection.datasource">java:comp/env/jdbc/MyApplicationDS</property>
        <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
        <property name="hibernate.jdbc.use_get_generated_keys">false</property>
        <mapping resource="TabUserPreferences.hbm.xml"/>
    </session-factory>

仅此而已.

XML components (classic style)

In the other hand, 如果你正在使用OX2 ,你需要复制文件 tomcat-hypersonic.properties, 粘贴到你的项目的根目录,修改为 tomcat-oracle.properties, 编辑这个文件和修改这一行:
hibernate.dialect=org.hibernate.dialect.HSQLDialect
变更为:
hibernate.dialect=org.hibernate.dialect.OracleDialect
然后,在你的项目中编辑文件 build.xml 并且变更:
<property name="configuration" value="tomcat-hypersonic" />

<property name="configuration" value="oracle-hypersonic" />